﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace day6_case2
{
    internal class Program
    {
        static void Main(string[] args)
        {

            Student stu1=new Student();
            stu1.Name = "zhangsan";
            stu1.Sex = "直升机";
            stu1.Age = 201;
            stu1.SayHello();

        }

        class Student
        {
            private string name;
            private int age;
            private string sex;


            public string Name
            {
                get { return name; }
                set { name = value; }
            }
            public int Age
            {
                get { return age; }
                set { 
                    if(value>0&&value<70) age = value;
                    else {

                        Console.WriteLine("程序员活不到{0}",value);
                        age = value;
                    }
                }
            }
            public string Sex
            {
                get { return sex; }
                set
                {
                    if (value == "男" || value == "女")
                    {
                        sex = value;
                    }
                    else
                    {
                        sex="未知";
                    }

                }

            }
            public void SayHello()
            {
                Console.WriteLine("大家好，我叫" + this.Name);
                Console.WriteLine("姓别" + this.Sex);
                Console.WriteLine("我今年" + Age + "岁了");
            
            }


        }
    }
}
